<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>${appname}</title>
<%@ include file="/WEB-INF/view/common/css_js_ace.jsp"%>
<%@ include file="/WEB-INF/view/common/css_js_ztree.jsp"%>
<script type="text/javascript">
	$(function() {
		$.checkBoxInit("status", '${fn:join(paramValues.status,', ')}'
				.split(','));
	});
	function search(form) {
		$(form).appendPagerParaStr();
		return true;
	}
	function formSubmit(){
	   $("#searchForm").submit();
	}
	/**
	 * 删除角色
	 */
	function userRoleDel(roleId,roleName){
		ui.confirm('确认删除角色['+roleName+']？',function(){
		    $.ajax({
		           type: "POST",
		           dataType:"json",
		           cache: false,
		           url: _ctx+"/pub/sysmgr/authmgr/del_role.do?roleId="+roleId,
		           beforeSend : function(){
		           },
		           success: function(resp){
		        	   if(resp.status == '1'){
						   ui.msg(resp.msg, 1);
						   ui.go(location.href);
					   }else{
						   ui.msg(resp.msg, 0);
					   }
		           },
		           error:function(){
		               ui.msg( '请求发送失败！',0 );
		           }
		    });
		});
	}
	function pushRoleInfo(){
		ui.confirm('确认要推送角色信息到统一用户管理平台？',function(){
		    $.ajax({
		           type: "POST",
		           dataType:"json",
		           cache: false,
		           url: _ctx+"/pub/sysmgr/authmgr/push_role.do",
		           beforeSend : function(){
		           },
		           success: function(resp){
		        	   if(resp.status == '1'){
						   ui.msg(resp.msg, 1);
					   }else{
						   ui.msg(resp.msg, 0);
					   }
		           },
		           error:function(){
		               ui.msg( '请求发送失败！',0 );
		           }
		    });
		});
	}
</script>
</head>
<body>
	<div class="main-container" id="main-container">
		<div class="main-container-inner">
			<div class="main-content" style="margin-left: 0px;">
				<div class="breadcrumbs" id="breadcrumbs">
					<ul class="breadcrumb" style="margin-left: 4px;">
						<li><i class="icon-home home-icon"></i>首页
						</li>
						<li>通用模块
						</li>
						<li class="active">角色管理</li>
					</ul>
				</div>

				<div class="page-content">
					<div class="row">
						<div class="col-xs-12">
							<div class="widget-box">
								<div class="widget-header header-color-white">
									<div class="widget-toolbar no-border">
										   <a class="btn btn-primary btn-xs" href="${ctx}/pub/sysmgr/authmgr/role_add.do" ><i class="icon-plus-sign icon-on-right"></i> 添加角色&nbsp;&nbsp;</a>
										  <c:if test="${isSlUams eq true}">
										    <a class="btn btn-primary btn-xs" href="javascript:pushRoleInfo()" ><i class="icon-plus-sign icon-on-right"></i> 推送角色&nbsp;&nbsp;</a>
										  </c:if>
										   <a href="#" data-action="collapse">
											<i class="icon-chevron-up"></i>
										</a>
									</div>
								</div>
								
								<div class="widget-body">
									<div class="widget-main">
										<form id="searchForm" class="form-search"
											action="${ctx}/pub/sysmgr/authmgr/role_list.do" method="post"
											onsubmit="return search(this)">
												<div class="row">
													<div class="col-xs-5">
														<div class="input-group">
															<span class="input-group-addon">角色名称</span> 
															<input type="text" class="form-control search-query" name="roleName" id="searchRoleName" value="${param.roleName}"/> 
														</div>
													</div>
													<div class="col-xs-5">
														<div class="input-group">
															<span class="input-group-addon">角色编码</span> 
															<input type="text" class="form-control search-query" name="roleCode" id="searchRoleCode" value="${param.roleCode}"/> 
														</div>
													</div>
												</div>
												
												<div class="hr12"></div>
												
												<div class="row">
													<div class="col-xs-5">
														<div class="input-group">
															<span class="input-group-addon">角色类型</span> 
															<select name="roleType" id="searchRoleType" class="form-control search-query" >
																<option value="">-请选择-</option>
																${cm:ctoption('authusertype', param.roleType)}
															</select>
														</div>
													</div>
													<div class="col-xs-5">
														<div class="input-group">
															<span class="input-group-addon">组织机构编码</span> 
															<input type="text" class="form-control search-query" name="orgCode" id="searchOrgCode" value="${param.orgCode}"/> 
														</div>
													</div>
													<div class="col-xs-2">
														<div class="input-group">
															<span class="input-group-btn">
																<button type="submit" class="btn btn-purple btn-sm"
																	onclick="return formSubmit();">
																	<i class="icon-search icon-on-right bigger-110"></i>&nbsp; 搜索
																</button> &nbsp;&nbsp;&nbsp;
															</span>
														</div>
													</div>
												</div>
										</form>
									</div>
								</div>
							</div>
							<div class="hr hr12 hr-dotted"></div>

							<div id="optDiv">
								<div class="table-responsive">
									<table id="sample-table-1"
										class="table table-striped table-bordered table-hover">
										<thead>
											<tr>
											    <th>
											      <label>
												    <input type="checkbox" class="ace" id="checkedAll"/>
												    <span class="lbl"></span>
												   </label>
                                                </th>
												<th>角色编码</th>
												<th>角色名称</th>
												<th>角色类型</th>
												<th>所属机构</th>
												<th>状态</th>
												<th>公共角色</th>
												<th>创建时间</th>
												<th>描述</th>
												<th>操作</th>
											</tr>
										</thead>
										<tbody>
											<c:forEach var="r" items="${roles}">
												<tr>
												    <td>
												     <label>
												      		<input type="checkbox" class="ace" name="roleCode" value="${r.roleCode}"/>
												      		<span class="lbl"></span>
												      </label>
												    </td>
													<td>${r.roleCode}&nbsp;</td>
													<td>${r.roleName}&nbsp;</td>
													<td>${cm:ctname('authusertype',r.roleType)}&nbsp;</td>
													<td>${r.orgCode}&nbsp;</td>
													<td>${cm:ctname('entity_status',r.roleStatus)}&nbsp;</td>
													<td>${cm:yesNoStr(r.isDefault)}&nbsp;</td>
													<td><fmt:formatDate value="${r.modified}" pattern="yyyy-MM-dd HH:mm:ss" />&nbsp;</td>
													<td>${r.remark}&nbsp;</td>
													<td align="center" >
														<div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
															<a class="blue" href="javascript:void(0);" onclick="javascript:self.location='${ctx}/pub/sysmgr/authmgr/get_role.do?roleId=${r.id}'" title="查看">
																 	<i class="icon-zoom-in bigger-130"></i>  
															 </a>
														    <a class="green" href="javascript:void(0);" onclick="javascript:self.location='${ctx}/pub/sysmgr/authmgr/role_update.do?roleId=${r.id}'" title="修改">
																 	<i class="icon-pencil bigger-130"></i> 
															 </a>
															  <a class="red" href="javascript:void(0);" onclick="javascript:userRoleDel('${r.id}','${r.roleName}')" title="删除">
																 <i class="icon-trash   bigger-130"></i> 
															 </a>
														</div>
													</td>
												</tr>
											</c:forEach>
										</tbody>
									</table>
									<jsp:include page="/WEB-INF/view/common/pg.jsp">
										<jsp:param value="${ctx}/pub/sysmgr/authmgr/role_list.do"
											name="url" />
										<jsp:param value="${_total}" name="total" />
										<jsp:param value="${_urlpara}" name="urlpara" />
									</jsp:include>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
